home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Workbench Design
/
WB Collection.iso
/
workbench werkzeuge
/
memory & system tools
/
tinymeter
/
source
/
tinymeter_prefs
/
main.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-04-07
|
81KB
|
2,152 lines
/// headers
/* MUI */
#include <libraries/mui.h>
/* System */
#include <dos/dos.h>
#include <graphics/gfxmacros.h>
#include <workbench/workbench.h>
#include <exec/memory.h>
#include <datatypes/pictureclass.h>
#include <libraries/locale.h>
/* Prototypes */
#include <clib/alib_protos.h>
#include <clib/exec_protos.h>
#include <clib/dos_protos.h>
#include <clib/icon_protos.h>
#include <clib/graphics_protos.h>
#include <clib/intuition_protos.h>
#include <clib/gadtools_protos.h>
#include <clib/utility_protos.h>
#include <clib/asl_protos.h>
#ifndef __GNUC__
#include <clib/muimaster_protos.h>
#else
#include <inline/muimaster.h>
#endif
/* ANSI C */
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#ifndef MAKE_ID
#define MAKE_ID(a,b,c,d) ((ULONG) (a)<<24 | (ULONG) (b)<<16 | (ULONG) (c)<<8 | (ULONG) (d))
#endif
///
#define STRINGARRAY YES
#include "TinyMeterPrefs.lh"
#include "tinymeter.h"
static struct MUI_CustomClass *CL_FieldsList;
static struct MUI_CustomClass *CL_ChooseFields;
static struct MUI_CustomClass *CL_MainWindow;
static struct MUI_CustomClass *CL_Composer;
#define USE_ABOUT_COLORS YES
#define USE_ABOUT_HEADER YES
#define USE_ABOUT_BODY YES
#define USE_QUESTION_COLORS YES
#define USE_QUESTION_HEADER YES
#define USE_QUESTION_BODY YES
enum { MEN_PROJECT=1,MEN_ABOUT,MEN_OPEN,MEN_SAVE,MEN_QUIT,CMP_LOAD, CMP_SAVE, CMP_CANCEL, CMP_PROJECT };
ULONG MainWindow_Finish(struct IClass *cl,Object *obj,Msg *msg);
/*************************************************************************************************/
/* misc funcs */
/*************************************************************************************************/
///
ULONG DoSuperNew(struct IClass *cl,Object *obj,ULONG tag1,...)
{
return(DoSuperMethod(cl,obj,OM_NEW,&tag1,NULL));
}
LONG xget(Object *obj,ULONG attribute)
{
LONG x;
get(obj,attribute,&x);
return(x);
}
initColor(struct GAU_Color *col,Object *obj)
{
struct MUI_PenSpec pspec;
if(col->pen==TRUE)
{
sprintf(&pspec.buf[0],"p%d\0",col->red);
set(obj,MUIA_Pendisplay_Spec,&pspec);
}
else
{
sprintf(&pspec.buf[0],"r%08lx,%08lx,%08lx\0",col->red,col->green,col->blue);
set(obj,MUIA_Pendisplay_Spec,&pspec);
}
}
ULONG convertColor(char *colstr)
{
}
getColor(struct GAU_Color *col,Object *obj)
{
struct MUI_PenSpec *pspec;
char *buf;
ULONG *dummy1,dummy2,dummy3;
get(obj,MUIA_Pendisplay_Spec,&pspec);
if(buf=(char *)AllocVec(256L,MEMF_CLEAR))
{
strcpy(buf,&pspec->buf[0]);
if(buf[0])
{
switch (buf[0])
{
case 'r':
col->pen=(UWORD)FALSE;
sscanf(buf+1,"%lx,%lx,%lx",&dummy1,&dummy2,&dummy3);
col->red=(ULONG)dummy1;
col->green=(ULONG)dummy2;
col->blue=(ULONG)dummy3;
break;
case 'p':
col->pen=(UWORD)TRUE;
sscanf(buf+1,"%ld",&col->red);
break;
case 'm':
MUI_RequestA(NULL,NULL,0,"TinyMeterPrefs","BAD LUCK!","Please do not use MUI colors.\nThey are not supported by TinyMeter!\n\nUse Colormap or a RBG color instead.",NULL);
break;
}
}
FreeVec(buf);
}
}
__saveds __asm void IntuiMsgFunc(__a1 struct IntuiMessage *imsg,__a2 struct FileRequester *req)
{
if (imsg->Class==IDCMP_REFRESHWINDOW)
DoMethod(req->fr_UserData,MUIM_Application_CheckRefresh);
}
char *getfilename(Object *win,char *title,char *pattern,BOOL save)
{
static char buf[512];
struct FileRequester *req;
struct Window *w;
static LONG left=-1,top=-1,width=-1,height=-1;
Object *app = (Object *)xget(win,MUIA_ApplicationObject);
char *res = NULL;
static const struct Hook IntuiMsgHook = { { 0,0 },(VOID *)IntuiMsgFunc,NULL,NULL };
get(win,MUIA_Window_Window,&w);
if (left==-1)
{
left = w->LeftEdge+w->BorderLeft+2;
top = w->TopEdge+w->BorderTop+2;
width = w->Width-w->BorderLeft-w->BorderRight-4;
height = w->Height-w->BorderTop-w->BorderBottom-4;
}
if (req=MUI_AllocAslRequestTags(ASL_FileRequest,
ASLFR_Window, w,
ASLFR_TitleText, title,
ASLFR_InitialLeftEdge, left,
ASLFR_InitialTopEdge , top,
ASLFR_InitialWidth , width,
ASLFR_InitialHeight , height,
ASLFR_InitialPattern , pattern,
ASLFR_DoSaveMode , save,
ASLFR_DoPatterns , TRUE,
ASLFR_RejectIcons , TRUE,
ASLFR_UserData , app,
ASLFR_IntuiMsgFunc , &IntuiMsgHook,
TAG_DONE))
{
set(app,MUIA_Application_Sleep,TRUE);
if (MUI_AslRequestTags(req,TAG_DONE))
{
if (*req->fr_File)
{
res = buf;
strcpy(buf,req->fr_Drawer);
AddPart(buf,req->fr_File,sizeof(buf));
}
left = req->fr_LeftEdge;
top = req->fr_TopEdge;
width = req->fr_Width;
height = req->fr_Height;
}
MUI_FreeAslRequest(req);
set(app,MUIA_Application_Sleep,FALSE);
}
return(res);
}
///
extern struct Library *SysBase,
*IntuitionBase,
*UtilityBase,
*GfxBase,
*DOSBase,
*IconBase;
struct Library *MUIMasterBase,
*LocaleBase;
struct tm_data *maindata;
struct Catalog *Catalog;
/*************************************************************************************************/
/* locale stuff */
/*************************************************************************************************/
///
char *GetStr(int num)
{
struct AppString *as = (struct AppString *)AppStrings;
while (as->as_ID != num) as++;
if (LocaleBase && Catalog) return(GetCatalogStr(Catalog,num,as->as_Str));
return((char *)as->as_Str);
}
VOID LocalizeStringArray(char **array)
{
char **x;
for (x=array;*x;x++)
*x = GetStr((int)*x);
}
VOID LocalizeNewMenu(struct NewMenu *nm)
{
for (;nm->nm_Type!=NM_END;nm++)
if (nm->nm_Label != NM_BARLABEL)
nm->nm_Label = GetStr((int)nm->nm_Label);
}
VOID InitLocale(VOID)
{
if (LocaleBase = OpenLibrary("locale.library",38))
Catalog = (struct Catalog *)OpenCatalog(NULL,"TinyMeterPrefs.catalog",TAG_DONE);
}
VOID ExitLocale(VOID)
{
if (Catalog) { CloseCatalog(Catalog); Catalog=NULL; }
if (LocaleBase) CloseLibrary(LocaleBase); { LocaleBase=NULL; }
}
Object *MakePen()
{
return(MUI_NewObject(MUIC_Poppen, MUIA_CycleChain, 1, MUIA_Window_Title, GetStr(MO_MakePen), TAG_DONE));
}
///
/*************************************************/
/* some pics */
/*************************************************/
#include "about.c"
#include "header_logo.c"
#include "tmp_logo.c"
#include "question.c"
/*************************************************/
/* default settings */
/*************************************************/
///
struct tm_sys_set default_set=
{
"TM40",
1,
10,
10,
400,
2,
"Workbench",
"XHelvetica.font",
11,
bg_file,
"hd0:prefs/patterns/leather",
FALSE,0x55555555,0x55555555,0x55555555,
5,
1,
0,
TRUE,
win_normal,
0,
4,
4,
8,
8,
bd_standard,
FALSE,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
FALSE,0x0,0x0,0x0,
idle_own
};
struct tm_gau_set g4=
{
typ_volume,
typ_histmeter,
200,
"Quill.font",
11,
"ChipMem",
"HD1: %kd kb,%p%% free",
"HD1:",
ind_right,
TRUE,
TRUE,
TRUE,
TRUE,
FALSE,
FALSE,
TRUE,
TRUE,2,0,0,
TRUE,2,0,0,
FALSE,0,0xFFFFFFFF,0,
FALSE,0,0,0xFFFFFFFF,
FALSE,0xFFFFFFFF,0,0,
TRUE,2,0,0,
TRUE,1,0,0,
TRUE,1,0,0,
NULL
};
struct tm_gau_set g3=
{
typ_idle,
typ_histmeter,
200,
"Quill.font",
11,
"ChipMem",
"CPU %p%% free",
"",
ind_right,
TRUE,
TRUE,
TRUE,
TRUE,
FALSE,
FALSE,
TRUE,
TRUE,2,0,0,
TRUE,2,0,0,
FALSE,0,0xFFFFFFFF,0,
FALSE,0,0,0xFFFFFFFF,
FALSE,0xFFFFFFFF,0,0,
TRUE,2,0,0,
TRUE,1,0,0,
TRUE,1,0,0,
&g4
};
struct tm_gau_set g2=
{
typ_fast,
typ_gauge,
20,
"XHelvetica.font",
11,
"FastMem",
"%td Bytes free",
"",
ind_right,
TRUE,
TRUE,
TRUE,
TRUE,
FALSE,
FALSE,
FALSE,
TRUE,2,0,0,
TRUE,2,0,0,
FALSE,0,0xFFFFFFFF,0,
FALSE,0,0,0xFFFFFFFF,
FALSE,0xFFFFFFFF,0,0,
TRUE,2,0,0,
TRUE,1,0,0,
TRUE,0,0,0,
&g3,
};
struct tm_gau_set g1=
{
typ_chip,
typ_gauge,
20,
"XHelvetica.font",
11,
"ChipMem",
"%td Bytes free",
"",
ind_right,
TRUE,
TRUE,
TRUE,
TRUE,
FALSE,
FALSE,
FALSE,
TRUE,2,0,0,
TRUE,2,0,0,
FALSE,0,0xFFFFFFFF,0,
FALSE,0,0,0xFFFFFFFF,
FALSE,0xFFFFFFFF,0,0,
TRUE,2,0,0,
TRUE,1,0,0,
TRUE,0,0,0,
&g2
};
struct tm_gau_set default_gauge=
{
NULL,
typ_gauge,
20,
"topaz.font",
8,
"",
"",
"",
ind_right,
TRUE,
TRUE,
TRUE,
TRUE,
FALSE,
FALSE,
TRUE,
TRUE,2,0,0,
TRUE,2,0,0,
FALSE,0,0xFFFFFFFF,0,
FALSE,0,0,0xFFFFFFFF,
FALSE,0xFFFFFFFF,0,0,
TRUE,2,0,0,
TRUE,1,0,0,
TRUE,0,0,0,
NULL
};
///
/*************************************************/
/* Drag & Drop lists */
/*************************************************/
/******************************************/
/* some hooks */
/******************************************/
///
char *gau_types[]=
{
(STRPTR)MDL_typ_space,
(STRPTR)MDL_typ_total,
(STRPTR)MDL_typ_chip,
(STRPTR)MDL_typ_fast,
(STRPTR)MDL_typ_volume,
(STRPTR)MDL_typ_cpu,
(STRPTR)MDL_typ_retina,
(STRPTR)MDL_typ_largest_chip,
(STRPTR)MDL_typ_largest_fast,
(STRPTR)MDL_typ_largest_total,
(STRPTR)MDL_typ_largest_retina,
(STRPTR)MDL_typ_clock,
0L,
};
__geta4 ULONG gau_consfunc(__a1 struct tm_gau_set *src)
{
/* struct tm_gau_set *dst;
if(dst=AllocVec(sizeof(struct tm_gau_set),0L))
{
CopyMem(src,dst, sizeof(struct tm_gau_set));
return(dst);
}
else return(0L);*/
return(src);
}
__geta4 void gau_desfunc(__a1 struct tm_gau_set *src)
{
FreeVec(src);
}
__geta4 ULONG gau_dispfunc(__a2 char **array,__a1 struct tm_gau_set *src)
{
if(src->type!=0)
{
*array++ = gau_types[src->type];
if(src->type==typ_volume)
{
*array = &src->expansion[0];
}
else *array = "";
}
else
{
*array++ = "-----------------";
*array = "";
}
return(0L);
}
static const struct Hook gau_ConstructHook = { { 0,0 }, (void *)gau_consfunc, NULL, NULL };
static const struct Hook gau_DestructHook = { { 0,0 }, (void *)gau_desfunc , NULL, NULL };
static const struct Hook gau_DisplayHook = { { 0,0 }, (void *)gau_dispfunc, NULL, NULL };
///
/******************************************/
/* FieldsList class */
/******************************************/
///
struct FieldsList_Data
{
LONG dummy;
};
ULONG FieldsList_DragQuery(struct IClass *cl,Object *obj,struct MUIP_DragDrop *msg)
{
if (msg->obj==obj) return(DoSuperMethodA(cl,obj,msg));
else if (msg->obj==(Object *)muiUserData(obj)) return(MUIV_DragQuery_Accept);
else return(MUIV_DragQuery_Refuse);
}
ULONG FieldsList_DragDrop(struct IClass *cl,Object *obj,struct MUIP_DragDrop *msg)
{
if (msg->obj==obj) return(DoSuperMethodA(cl,obj,msg));
else
{
struct tm_gau_set *entry;
LONG dropmark;
LONG sortable;
LONG active;
get(obj,MUIA_List_DragSortable,&sortable);
if (sortable)
{
get(msg->obj,MUIA_List_Active,&active);
if(entry=(struct tm_gau_set *)AllocVec(sizeof(struct tm_gau_set),MEMF_CLEAR))
{
CopyMem(&default_gauge,entry, sizeof(struct tm_gau_set));
entry->type = (UWORD)active;
if(active==typ_clock_) entry->gauge_type=typ_clock;
get (obj, MUIA_List_DropMark, &dropmark);
DoMethod(obj, MUIM_List_InsertSingle, entry,dropmark);
set (obj, MUIA_List_Active, dropmark);
set (msg->obj, MUIA_List_Active, MUIV_List_Active_Off);
}
}
else
{
DoMethod(msg->obj,MUIM_List_Remove,MUIV_List_Remove_Active);
}
return(obj);
}
}
__geta4 ULONG FieldsList_Dispatcher(__a0 struct IClass *cl,__a2 Object *obj,__a1 Msg msg)
{
switch (msg->MethodID)
{
case MUIM_DragQuery: return(FieldsList_DragQuery(cl,obj,(APTR)msg));
case MUIM_DragDrop : return(FieldsList_DragDrop (cl,obj,(APTR)msg));
}
return(DoSuperMethodA(cl,obj,msg));
}
///
/******************************************/
/* ChooseFields class */
/******************************************/
///
Object *available, *visible;
struct ChooseFields_Data
{
ULONG dummy;
};
struct ComposerMsg
{
ULONG MethodID;
Object *listview;
struct ChooseFields_Data *data;
};
#define Dis_ID_DoubleClickComposer 1
#define Dis_ID_ComposerClose 2
#define Dis_ID_Composer_Save 3
#define Composer_Originator ( TAG_USER + 1 )
#define Gauge_Settings ( TAG_USER + 2 )
static ULONG DoubleClickComposer(struct IClass *cl,Object *obj, struct ComposerMsg *msg)
{
struct tm_gau_set *desc;
Object *tmp;
DoMethod(msg->listview,MUIM_List_GetEntry,MUIV_List_GetEntry_Active,&desc);
if (desc)
{
set((Object *)xget(obj,MUIA_ApplicationObject),MUIA_Application_Sleep,TRUE);
if (desc->type!=typ_none)
{
if (tmp = (APTR)NewObject(CL_Composer->mcc_Class,NULL,
Composer_Originator, obj,
Gauge_Settings, desc,
TAG_DONE))
{
DoMethod((Object *)xget(obj,MUIA_ApplicationObject),OM_ADDMEMBER,tmp);
set(tmp,MUIA_Window_Open,TRUE);
}
else DisplayBeep(0);
}
set((Object *)xget(obj,MUIA_ApplicationObject),MUIA_Application_Sleep,FALSE);
}
return((ULONG)0);
}
static ULONG ChooseFields_New(struct IClass *cl,Object *obj,struct opSet *msg)
{
obj = (Object *)DoSuperNew(cl,obj,
MUIA_Group_Columns, 2,
MUIA_Group_VertSpacing, 1,
Child, TextObject, MUIA_Text_Contents, GetStr(MDL_Available), End,
Child, TextObject, MUIA_Text_Contents, GetStr(MDL_Selected ), End,
Child, ListviewObject,
MUIA_Listview_DragType, 1,
MUIA_Listview_List, available = NewObject(CL_FieldsList->mcc_Class,NULL,
InputListFrame,
MUIA_List_SourceArray , gau_types,
MUIA_List_ShowDropMarks, FALSE,
TAG_DONE),
End,
Child, ListviewObject,
MUIA_Listview_DragType, 1,
MUIA_Listview_DoubleClick, TRUE,
MUIA_Listview_List, visible = NewObject(CL_FieldsList->mcc_Class,NULL,
InputListFrame,
MUIA_List_ConstructHook, &gau_ConstructHook,
MUIA_List_DestructHook , &gau_DestructHook,
MUIA_List_DisplayHook , &gau_DisplayHook,
MUIA_List_Format , "MIW=50 MAW=100 BAR,",
MUIA_List_DragSortable , TRUE,
TAG_DONE),
End,
End;
if (obj)
{
DoMethod(visible,MUIM_Notify,MUIA_Listview_DoubleClick,TRUE,obj,2,Dis_ID_DoubleClickComposer,visible);
set(available,MUIA_UserData,visible);
set(visible,MUIA_UserData,available);
set(available,MUIA_ShortHelp,GetStr(MDH_Available));
set(visible,MUIA_ShortHelp,GetStr(MDH_Selected));
}
return((ULONG)obj);
}
struct ComposerFinishMsg
{
ULONG MethodID;
Object *win;
ULONG ok;
};
ULONG Composer_Close(struct IClass *cl, Object *obj, struct ComposerFinishMsg *msg)
{
DoMethod(msg->win,Dis_ID_Composer_Save,msg->win,msg->ok);
set(msg->win,MUIA_Window_Open,FALSE);
DoMethod((Object *)xget(obj,MUIA_ApplicationObject),OM_REMMEMBER,msg->win);
MUI_DisposeObject(msg->win);
return((ULONG)0L);
}
static __saveds __asm ULONG ChooseFields_Dispatcher(__a0 struct IClass *cl,__a2 Object *obj,__a1 Msg msg)
{
switch (msg->MethodID)
{
case OM_NEW : return(ChooseFields_New (cl,obj,(APTR)msg));
case Dis_ID_DoubleClickComposer : return(DoubleClickComposer (cl,obj,(APTR)msg));
case Dis_ID_ComposerClose : return(Composer_Close (cl,obj,(APTR)msg));
}
return(DoSuperMethodA(cl,obj,msg));
}
///
/*************************************************/
/* Composer Class */
/*************************************************/
/******************************************/
/* Composer Menu */
/******************************************/
///
struct NewMenu CmpMenuData[] =
{
{ NM_TITLE, (STRPTR)MCM_Gauge , 0 ,0 ,0 ,(APTR)CMP_PROJECT },
{ NM_ITEM , (STRPTR)MCM_Open ,"O",0 ,0 ,(APTR)CMP_LOAD },
{ NM_ITEM , (STRPTR)MCM_SaveAs ,"S",0 ,0 ,(APTR)CMP_SAVE },
{ NM_ITEM , NM_BARLABEL , 0 ,0 ,0 ,(APTR)0 },
{ NM_ITEM , (STRPTR)MCM_Cancel ,"C",0 ,0 ,(APTR)CMP_CANCEL },
{ NM_END,NULL,0,0,0,(APTR)0 }
};
///
/******************************************/
/* Composer class */
/******************************************/
///
#define Dis_ID_DoubleClickDevice 8
#define Dis_ID_SaveGauge 9
#define Dis_ID_LoadGauge 10
#define Dis_ID_ShowFormatHelp 11
struct Composer_Data
{
Object *ST_Label,
*PO_Device,
*ST_Device,
*CY_Type,
*NB_Height,
*CS_Colors[16],
*ST_Font,
*ST_Format,
*CM_3D,
*CM_Border,
*CM_Bg,
*CM_Shadow,
*CM_NoGauge,
*CM_NoFmt,
*CM_NoBase,
*CY_Indent,
*VL_Device,
*originator,
*sub_win;
struct tm_gau_set *gauge;
};
static ULONG DoubleClickDev(struct IClass *cl,Object *obj, struct DoubleClkMsg *msg)
{
char *my_ptr;
struct Composer_Data *data = INST_DATA(cl,obj);
DoMethod(data->VL_Device,MUIM_List_GetEntry,MUIV_List_GetEntry_Active,&my_ptr);
if(my_ptr)
{
set(data->ST_Device,MUIA_String_Contents,my_ptr);
DoMethod(data->PO_Device,MUIM_Popstring_Close,0L);
return(DoSuperMethodA(cl,obj,msg));
}
else return(0L);
}
ULONG Composer_Save(struct IClass *cl, Object *obj, struct ComposerFinishMsg *msg)
{
int i;
ULONG dummy;
struct Composer_Data *data = INST_DATA(cl,obj);
if(msg->ok==TRUE)
{
for(i=0;i<8;i++) getColor(&data->gauge->Colors[i],data->CS_Colors[i]);
get(data->ST_Label ,MUIA_String_Contents,&dummy); strcpy(&data->gauge->label[0] , dummy ? (char *)dummy : " " );
get(data->ST_Device ,MUIA_String_Contents,&dummy); strcpy(&data->gauge->expansion[0], dummy ? (char *)dummy : " " );
get(data->CY_Type ,MUIA_Cycle_Active ,&dummy); data->gauge->gauge_type =(UWORD)dummy;
get(data->NB_Height ,MUIA_Numeric_Value ,&dummy); data->gauge->size_y =(UWORD)dummy-100;
get(data->CM_3D ,MUIA_Selected ,&dummy); data->gauge->sty_3d =(UWORD)dummy;
get(data->CM_Border ,MUIA_Selected ,&dummy); data->gauge->sty_border =(UWORD)dummy;
get(data->CM_Bg ,MUIA_Selected ,&dummy); data->gauge->sty_bg =(UWORD)dummy;
get(data->CM_Shadow ,MUIA_Selected ,&dummy); data->gauge->sty_shadow =(UWORD)dummy;
get(data->CM_NoGauge,MUIA_Selected ,&dummy); data->gauge->sty_nogauge =(UWORD)dummy;
get(data->CM_NoFmt ,MUIA_Selected ,&dummy); data->gauge->sty_noformat=(UWORD)dummy;
get(data->CM_NoBase ,MUIA_Selected ,&dummy); data->gauge->sty_nobase =(UWORD)dummy;
get(data->CY_Indent ,MUIA_Cycle_Active ,&dummy); data->gauge->indent =(UWORD)dummy;
get(data->ST_Font ,MUIA_String_Contents,&dummy); sscanf((char *)dummy,"%[^/]/%d",&data->gauge->font[0],&i);
strcat(&data->gauge->font[0],".font"); data->gauge->font_size=(WORD)i;
get(data->ST_Format ,MUIA_String_Contents,&dummy); strcpy((char *)&data->gauge->format[0], dummy ? (char *)dummy : " " );
}
DoMethod(visible,MUIM_List_Redraw,MUIV_List_Redraw_All);
}
char *types[] ={(STRPTR)MCL_Normal,(STRPTR)MCL_Historymeter,0L};
char *indent[] ={(STRPTR)MCL_center,(STRPTR)MCL_left,(STRPTR)MCL_right,0L};
char *regcomposer[] ={(STRPTR)MCR_general,(STRPTR)MCR_flags,(STRPTR)MCR_colors,0L};
insertComposerSettings(struct tm_gau_set *gauge, struct Composer_Data *data)
{
int i;
char dummy[256];
for(i=0;i<8;i++)
{
initColor(&gauge->Colors[i],data->CS_Colors[i]);
if(gauge->type == typ_clock_) set(data->CS_Colors[i],MUIA_Disabled, TRUE);
}
set(data->NB_Height,MUIA_Numeric_Value,gauge->size_y+100);
if(gauge->type != typ_volume) set(data->PO_Device, MUIA_Disabled, TRUE);
if((gauge->gauge_type==typ_histmeter)||(gauge->type==typ_clock_))
{
set(data->ST_Label, MUIA_Disabled, TRUE);
set(data->CM_3D, MUIA_Disabled, TRUE);
set(data->CM_Shadow, MUIA_Disabled, TRUE);
if(gauge->type==typ_clock_)
{
set(data->CM_Bg, MUIA_Disabled, TRUE);
set(data->CS_Colors[col_format] ,MUIA_Disabled,FALSE);
set(data->CS_Colors[col_dark] ,MUIA_Disabled,FALSE);
set(data->CM_Shadow ,MUIA_Disabled,FALSE);
set(data->CM_Border ,MUIA_Disabled, TRUE);
set(data->CM_NoGauge ,MUIA_Disabled, TRUE);
set(data->CM_NoFmt ,MUIA_Disabled, TRUE);
set(data->CM_NoBase ,MUIA_Disabled, TRUE);
set(data->CY_Type ,MUIA_Disabled, TRUE);
}
}
set(data->CM_3D ,MUIA_Selected,gauge->sty_3d);
set(data->CM_Border ,MUIA_Selected,gauge->sty_border);
set(data->CM_Bg ,MUIA_Selected,gauge->sty_bg);
set(data->CM_Shadow ,MUIA_Selected,gauge->sty_shadow);
set(data->CM_NoGauge,MUIA_Selected,gauge->sty_nogauge);
set(data->CM_NoFmt ,MUIA_Selected,gauge->sty_noformat);
set(data->CM_NoBase ,MUIA_Selected,gauge->sty_nobase);
set(data->ST_Format ,MUIA_String_Contents,&gauge->format[0]);
strcpy(&dummy[0],gauge->font);
sprintf((char *)&dummy[strlen(&dummy[0])-5],"/%d",gauge->font_size);
set(data->ST_Font ,MUIA_String_Contents,&dummy[0]);
set(data->ST_Device ,MUIA_String_Contents,&gauge->expansion[0]);
set(data->ST_Label ,MUIA_String_Contents,&gauge->label[0]);
set(data->CY_Indent ,MUIA_Cycle_Active,gauge->indent);
set(data->CY_Type ,MUIA_Cycle_Active,gauge->gauge_type);
}
LoadGaugeSet(struct IClass *cl,Object *obj)
{
struct Composer_Data *data=INST_DATA(cl,obj);
char *file;
ULONG my_file;
ULONG buf;
UWORD old_type;
char old_expansion[128];
if(file=getfilename(obj,GetStr(MCM_LoadGauge),"#?.tmgauge",FALSE))
{
if(my_file=(ULONG)Open(file,MODE_OLDFILE))
{
Read(my_file,&buf,4L);
if(buf==0x544D4731)
{
old_type=data->gauge->type;
CopyMem(&data->gauge->expansion[0],&old_expansion[0],128L);
Read(my_file,data->gauge,sizeof(struct tm_gau_set));
data->gauge->type=old_type;
CopyMem(&old_expansion[0],&data->gauge->expansion[0],128L);
insertComposerSettings(data->gauge,data);
}
else MUI_RequestA((Object *)xget(obj,MUIA_ApplicationObject),obj,0,"TinyMeterPrefs",GetStr(MCM_NotTmGauge_fmt),GetStr(MCM_NotTmGauge),NULL);
Close(my_file);
}
}
}
SaveGaugeSet(struct IClass *cl,Object *obj)
{
struct Composer_Data *data=INST_DATA(cl,obj);
char *file;
ULONG buf,my_file;
struct ComposerFinishMsg msg;
msg.ok=TRUE;
Composer_Save( cl,obj,&msg);
buf=0x544D4731;
if(file=getfilename(obj,GetStr(MCM_SaveGauge),"#?.tmgauge",TRUE))
{
if(my_file=Open(file,MODE_NEWFILE))
{
Write(my_file,&buf,4L);
Write(my_file,data->gauge,sizeof(struct tm_gau_set));
Close(my_file);
}
}
}
Object *WI_HelpFmt,
*WI_HelpClock;
static ULONG Composer_New(struct IClass *cl,Object *obj,struct opSet *msg)
{
struct Composer_Data *data;
struct tm_gau_set *gauge;
Object *BT_Use,
*BT_Cancel,
*ST_Label,
*PO_Device,
*ST_Device,
*CY_Type,
*NB_Height,
*CS_Colors[8],
*ST_Font,
*ST_Format,
*CM_3D,
*CM_Border,
*CM_Bg,
*CM_Shadow,
*CM_NoGauge,
*CM_NoFmt,
*CM_NoBase,
*CY_Indent,
*LV_Device,
*VL_Device,
*CMP_Menu,
*BT_Quest;
if(gauge = (struct tm_gau_set *)GetTagData(Gauge_Settings,0,msg->ops_AttrList))
{
if( obj = (Object *)DoSuperNew(cl,obj,
MUIA_Window_Title , gau_types[gauge->type] ,
MUIA_Window_ID , MAKE_ID('T','M','C','O'),
MUIA_Window_Menustrip , CMP_Menu = MUI_MakeObject(MUIO_MenustripNM,CmpMenuData,0),
WindowContents, VGroup, ButtonFrame,
Child, HGroup, MUIA_Background, MUII_SHADOW,
Child, BodychunkObject,
MUIA_FixWidth , HEADER_LOGO_WIDTH ,
MUIA_FixHeight , HEADER_LOGO_HEIGHT,
MUIA_Bitmap_Width , HEADER_LOGO_WIDTH ,
MUIA_Bitmap_Height , HEADER_LOGO_HEIGHT,
MUIA_Bodychunk_Depth , HEADER_LOGO_DEPTH ,
MUIA_Bodychunk_Body , (UBYTE *)header_logo_body,
MUIA_Bodychunk_Compression, HEADER_LOGO_COMPRESSION,
MUIA_Bodychunk_Masking , HEADER_LOGO_MASKING,
MUIA_Bitmap_SourceColors , (ULONG *)header_logo_colors,
MUIA_Bitmap_Transparent , 0,
End,
Child, HSpace(0),
End,
Child, RegisterGroup(regcomposer),
MUIA_Register_Frame, TRUE,
Child, ColGroup(2),
Child, VSpace(0),
Child, VSpace(0),
Child, Label(GetStr(MCO_type)),
Child, CY_Type=CycleObject,
MUIA_Cycle_Entries, types,
End,
Child, Label(GetStr(MCO_label)),
Child, ST_Label=String(0L,16),
Child, Label(GetStr(MCO_height)),
Child, ColGroup(2), Child, NB_Height=MUI_MakeObject(MUIO_NumericButton,NULL,100,400,GetStr(MCO_height_fmt)), Child, HVSpace, End,
Child, Label(GetStr(MCO_font)),
Child, PopaslObject,
MUIA_Popstring_String, ST_Font=(Object *)String(0L,80),
MUIA_Popstring_Button, PopButton(MUII_PopUp),
MUIA_Popasl_Type , ASL_FontRequest,
ASLFO_TitleText , GetStr(MCO_sel_font),
End,
Child, Label(GetStr(MCO_device)),
Child, PO_Device=PopobjectObject,
MUIA_Popstring_String, ST_Device=String(0L,128),
MUIA_Popstring_Button, PopButton(MUII_PopUp),
MUIA_Popobject_Object, LV_Device=ListviewObject,
MUIA_Weight, 20,
MUIA_Listview_Input, TRUE,
MUIA_Listview_DoubleClick, TRUE,
MUIA_Listview_List, VL_Device=VolumelistObject,
InputListFrame,
MUIA_Dirlist_Directory, "ram:",
End,
End,
End,
Child, VSpace(0),
Child, VSpace(0),
End,
Child, ColGroup(2),
Child, VSpace(0),
Child, VSpace(0),
Child, Label(GetStr(MCO_3dlook)),
Child, CM_3D=CheckMark(gauge->sty_3d),
Child, Label(GetStr(MCO_border)),
Child, CM_Border=CheckMark(gauge->sty_border),
Child, Label(GetStr(MCO_nobgcol)),
Child, CM_Bg=CheckMark(gauge->sty_bg),
Child, Label(GetStr(MCO_shadow)),
Child, CM_Shadow=CheckMark(gauge->sty_shadow),
Child, Label(GetStr(MCO_disgaug)),
Child, CM_NoGauge=CheckMark(gauge->sty_nogauge),
Child, Label(GetStr(MCO_disfmt)),
Child, CM_NoFmt=CheckMark(gauge->sty_noformat),
Child, Label(GetStr(MCO_disbas)),
Child, CM_NoBase=CheckMark(gauge->sty_nobase),
Child, VSpace(0),
Child, VSpace(0),
End,
Child, ColGroup(2),
Child, ColGroup(2),
Child, VSpace(0),
Child, VSpace(0),
Child, Label(GetStr(MCO_col_label)),
Child, CS_Colors[col_label] =MakePen(),
Child, Label(GetStr(MCO_col_fmt)),
Child, CS_Colors[col_format] =MakePen(),
Child, Label(GetStr(MCO_col_bas)),
Child, CS_Colors[col_base] =MakePen(),
Child, Label(GetStr(MCO_col_cur)),
Child, CS_Colors[col_current] =MakePen(),
Child, VSpace(0),
Child, VSpace(0),
End,
Child, ColGroup(2),
Child, VSpace(0),
Child, VSpace(0),
Child, Label(GetStr(MCO_col_neg)),
Child, CS_Colors[col_negative] =MakePen(),
Child, Label(GetStr(MCO_col_bright)),
Child, CS_Colors[col_bright] =MakePen(),
Child, Label(GetStr(MCO_col_dark)),
Child, CS_Colors[col_dark] =MakePen(),
Child, Label(GetStr(MCO_col_bg)),
Child, CS_Colors[col_bg] =MakePen(),
Child, VSpace(0),
Child, VSpace(0),
End,
End,
End,
Child, HGroup, GroupFrame,
Child, Label(GetStr(MCO_fmt)),
Child, ST_Format=(Object *)String(0L,128),
Child, BT_Quest=BodychunkObject,
ButtonFrame,
MUIA_InputMode , MUIV_InputMode_RelVerify,
MUIA_FixWidth , QUESTION_WIDTH ,
MUIA_FixHeight , QUESTION_HEIGHT,
MUIA_Bitmap_Width , QUESTION_WIDTH ,
MUIA_Bitmap_Height , QUESTION_HEIGHT,
MUIA_Bodychunk_Depth , QUESTION_DEPTH ,
MUIA_Bodychunk_Body , (UBYTE *)question_body,
MUIA_Bodychunk_Compression, QUESTION_COMPRESSION,
MUIA_Bodychunk_Masking , QUESTION_MASKING,
MUIA_Bitmap_SourceColors , (ULONG *)question_colors,
MUIA_Bitmap_Transparent , 0,
End,
Child, CY_Indent=CycleObject,
MUIA_Weight, 0,
MUIA_Cycle_Entries, indent,
End,
End,
Child, HGroup,
Child, BT_Use = (Object *)SimpleButton(GetStr(MCO_Use)),
Child, BT_Cancel = (Object *)SimpleButton(GetStr(MCO_Cancel)),
End,
End,
End)
{
int i;
data=INST_DATA(cl,obj);
data->gauge = gauge;
data->ST_Label = ST_Label;
set(ST_Label,MUIA_ShortHelp,GetStr(MOH_Label));
data->PO_Device = PO_Device;
set(PO_Device,MUIA_ShortHelp,GetStr(MOH_Device));
data->ST_Device = ST_Device;
data->CY_Type = CY_Type;
data->NB_Height = NB_Height;
data->CM_3D = CM_3D;
data->CM_Border = CM_Border;
set(CM_Border,MUIA_ShortHelp,GetStr(MOH_3d));
data->CM_Bg = CM_Bg;
set(CM_Bg,MUIA_ShortHelp,GetStr(MOH_Bg));
data->CM_Shadow = CM_Shadow;
data->CM_NoGauge = CM_NoGauge;
set(CM_NoGauge,MUIA_ShortHelp,GetStr(MOH_NoGauge));
data->CM_NoFmt = CM_NoFmt;
set(CM_NoFmt,MUIA_ShortHelp,GetStr(MOH_NoFmt));
data->CM_NoBase = CM_NoBase;
set(CM_NoBase,MUIA_ShortHelp,GetStr(MOH_NoBase));
data->CY_Indent = CY_Indent;
data->ST_Font = ST_Font;
data->VL_Device = VL_Device;
data->ST_Format = ST_Format;
for(i=0;i<8;i++) data->CS_Colors[i]=CS_Colors[i];
insertComposerSettings(gauge,data);
data->originator = (Object *)GetTagData(Composer_Originator,0,msg->ops_AttrList);
DoMethod(LV_Device, MUIM_Notify,MUIA_Listview_DoubleClick ,TRUE,obj,1,Dis_ID_DoubleClickDevice);
DoMethod(CY_Type, MUIM_Notify,MUIA_Cycle_Active,typ_gauge ,ST_Label,3,MUIM_Set,MUIA_Disabled,FALSE);
DoMethod(CY_Type, MUIM_Notify,MUIA_Cycle_Active,typ_histmeter,ST_Label,3,MUIM_Set,MUIA_Disabled,TRUE);
DoMethod(CY_Type, MUIM_Notify,MUIA_Cycle_Active,typ_gauge ,CM_3D,3,MUIM_Set,MUIA_Disabled,FALSE);
DoMethod(CY_Type, MUIM_Notify,MUIA_Cycle_Active,typ_histmeter,CM_3D,3,MUIM_Set,MUIA_Disabled,TRUE);
DoMethod(CY_Type, MUIM_Notify,MUIA_Cycle_Active,typ_gauge ,CM_Shadow,3,MUIM_Set,MUIA_Disabled,FALSE);
DoMethod(CY_Type, MUIM_Notify,MUIA_Cycle_Active,typ_histmeter,CM_Shadow,3,MUIM_Set,MUIA_Disabled,TRUE);
DoMethod(CY_Type, MUIM_Notify,MUIA_Cycle_Active,typ_gauge ,CM_Bg,3,MUIM_Set,MUIA_Disabled,FALSE);
DoMethod(CY_Type, MUIM_Notify,MUIA_Cycle_Active,typ_histmeter,CM_Bg,3,MUIM_Set,MUIA_Disabled,TRUE);
if(gauge->type!=typ_clock_) DoMethod(BT_Quest, MUIM_Notify,MUIA_Pressed,FALSE, WI_HelpFmt ,3,MUIM_Set,MUIA_Window_Open,TRUE);
else DoMethod(BT_Quest, MUIM_Notify,MUIA_Pressed,FALSE, WI_HelpClock ,3,MUIM_Set,MUIA_Window_Open,TRUE);
DoMethod(obj, MUIM_Notify,MUIA_Window_CloseRequest,TRUE, MUIV_Notify_Application,6,MUIM_Application_PushMethod,data->originator,3,Dis_ID_ComposerClose,obj,FALSE);
DoMethod(BT_Cancel, MUIM_Notify,MUIA_Pressed,FALSE, MUIV_Notify_Application,6,MUIM_Application_PushMethod,data->originator,3,Dis_ID_ComposerClose,obj,FALSE);
DoMethod(BT_Use, MUIM_Notify,MUIA_Pressed,FALSE, MUIV_Notify_Application,6,MUIM_Application_PushMethod,data->originator,3,Dis_ID_ComposerClose,obj,TRUE);
DoMethod(obj, MUIM_Notify,MUIA_Window_MenuAction,CMP_SAVE,obj,1,Dis_ID_SaveGauge);
DoMethod(obj, MUIM_Notify,MUIA_Window_MenuAction,CMP_LOAD,obj,1,Dis_ID_LoadGauge);
return((ULONG)obj);
}
}
return(0L);
}
static __saveds __asm ULONG ComposerDispatcher(__a0 struct IClass *cl,__a2 Object *obj,__a1 Msg msg)
{
switch (msg->MethodID)
{
case OM_NEW : return(Composer_New (cl,obj,(APTR)msg));
case Dis_ID_Composer_Save : return(Composer_Save (cl,obj,(APTR)msg));
case Dis_ID_DoubleClickDevice : return(DoubleClickDev (cl,obj,(APTR)msg));
case Dis_ID_SaveGauge : return(SaveGaugeSet (cl,obj));
case Dis_ID_LoadGauge : return(LoadGaugeSet (cl,obj));
}
return(DoSuperMethodA(cl,obj,msg));
}
///
/*************************************************/
/* Main Window and his dispatcher */
/*************************************************/
/******************************************/
/* some vars */
/******************************************/
///
#define Dis_ID_DoubleClick1 1
#define Dis_ID_Finish 2
#define Dis_ID_DoubleClick2 3
#define Dis_ID_Save 4
#define Dis_ID_Snap 5
#define Dis_ID_Load 6
struct NewMenu MenuData1[] =
{
{ NM_TITLE, (STRPTR)MM_Project , 0 ,0 ,0 ,(APTR)MEN_PROJECT },
{ NM_ITEM , (STRPTR)MM_Open ,"O",0 ,0 ,(APTR)MEN_OPEN },
{ NM_ITEM , (STRPTR)MM_SaveAs ,"S",0 ,0 ,(APTR)MEN_SAVE },
{ NM_ITEM , (STRPTR)MM_About ,"?",0 ,0 ,(APTR)MEN_ABOUT },
{ NM_ITEM , NM_BARLABEL , 0 ,0 ,0 ,(APTR)0 },
{ NM_ITEM , (STRPTR)MM_Quit ,"Q",0 ,0 ,(APTR)MEN_QUIT },
{ NM_END,NULL,0,0,0,(APTR)0 }
};
struct ls_layout
{
char *entry_desc;
BYTE entry_selected;
BOOL entry_max;
char *entry[6];
};
struct ls_layout switches[]=
{
{(STRPTR)ML_Window, 0,0,0,0,0,0,0,0},
{(STRPTR)ML_BgPic, 0,2,(STRPTR)ML_BgPic_None,(STRPTR)ML_BgPic_File,(STRPTR)ML_BgPic_Snap,0,0,0},
{(STRPTR)ML_WinBeh, 0,2,(STRPTR)ML_WinBeh_Normal,(STRPTR)ML_WinBeh_Front,(STRPTR)ML_WinBeh_Back,0,0,0},
{(STRPTR)ML_WinMov, 0,1,(STRPTR)ML_WinMov_Normal,(STRPTR)ML_WinMov_Fixed,0,0,0,0},
{(STRPTR)ML_Border, 0,3,(STRPTR)ML_Border_None,(STRPTR)ML_Border_Simple,(STRPTR)ML_Border_Standard,(STRPTR)ML_Border_Double,0,0},
{(STRPTR)ML_Startup, 0,0,0,0,0,0,0,0},
{(STRPTR)ML_ScrNot, 0,1,(STRPTR)ML_ScrNot_No,(STRPTR)ML_ScrNot_Yes,0,0,0,0},
{(STRPTR)ML_Cpu, 0,2,(STRPTR)ML_Cpu_None,(STRPTR)ML_Cpu_Executive,(STRPTR)ML_Cpu_Own,0,0,0},
NULL
};
char *mainlister[]=
{
(STRPTR)MOL_General,
(STRPTR)MOL_Compose,
NULL
};
char *sublister[]=
{
(STRPTR)MOL_sub_General,
(STRPTR)MOL_sub_Window,
(STRPTR)MOL_sub_Layout,
NULL
};
struct MainData
{
ULONG dummy;
};
char *pubscr[256];
struct BitMap my_bmp;
Object *BT_Save,
*BT_Use,
*BT_Test,
*BT_Cancel,
*ls_Switch,
*ls_PubScr,
*lv_Switch,
*lv_PubScr,
*ST_PubScr,
*PO_PubScr,
*MN_Main,
*WI_About,
*IN_posx,
*IN_posy,
*IN_sizx,
*ST_bg,
*NB_wait,
*NB_mem,
*NB_vol,
*NB_bordx,
*NB_bordy,
*NB_spcx,
*NB_spcy,
*NB_col,
*MN_Colors[3],
*BT_Snap,
*LV_Composer;
///
/******************************************/
/* some listview hooks */
/******************************************/
///
__saveds __asm APTR lay_consfunc(__a1 struct ls_layout *src)
{
return(src);
}
__saveds __asm ULONG lay_desfunc(__a1 struct ls_layout *src)
{
return(0L);
}
__saveds __asm void lay_dispfunc(__a2 char **array,__a1 struct ls_layout *src)
{
*array++ = src->entry_desc;
*array = src->entry[src->entry_selected];
}
static const struct Hook lay_ConstructHook = { { 0,0 }, (void *)lay_consfunc, NULL, NULL };
static const struct Hook lay_DestructHook = { { 0,0 }, (void *)lay_desfunc , NULL, NULL };
static const struct Hook lay_DisplayHook = { { 0,0 }, (void *)lay_dispfunc, NULL, NULL };
///
/******************************************/
/* load settings and a method */
/******************************************/
///
#define load_standard 0
#define load_file 1
struct LoadSetMsg
{
ULONG MethodID;
ULONG what;
};
insertSettings(struct tm_sys_set *set,struct tm_gau_set *list)
{
struct ls_layout *src;
set(NB_col ,MUIA_Numeric_Value,set->colums);
set(NB_bordx,MUIA_Numeric_Value,set->win_border_x);
set(NB_bordy,MUIA_Numeric_Value,set->win_border_y);
set(NB_spcx ,MUIA_Numeric_Value,set->win_space_x);
set(NB_spcy ,MUIA_Numeric_Value,set->win_space_y);
set(NB_wait ,MUIA_Numeric_Value,set->start_wait);
set(NB_mem ,MUIA_Numeric_Value,set->mem_refresh);
set(NB_vol ,MUIA_Numeric_Value,set->vol_refresh);
DoMethod(ls_Switch,MUIM_List_GetEntry,1,&src);
src->entry_selected=set->bg_type;
DoMethod(ls_Switch,MUIM_List_GetEntry,2,&src);
src->entry_selected=set->win_backfront;
DoMethod(ls_Switch,MUIM_List_GetEntry,3,&src);
src->entry_selected=set->win_move;
DoMethod(ls_Switch,MUIM_List_GetEntry,4,&src);
src->entry_selected=set->bd_type;
DoMethod(ls_Switch,MUIM_List_GetEntry,6,&src);
src->entry_selected=set->start_usescreennotify;
DoMethod(ls_Switch,MUIM_List_GetEntry,7,&src);
src->entry_selected=set->Executive;
initColor(&set->bg_color,MN_Colors[0]);
initColor(&set->bright_color,MN_Colors[1]);
initColor(&set->dark_color,MN_Colors[2]);
set(ST_PubScr, MUIA_String_Contents ,&set->pub_name[0]);
set(IN_posx, MUIA_String_Integer ,set->x_pos);
set(IN_posy, MUIA_String_Integer ,set->y_pos);
set(IN_sizx, MUIA_String_Integer ,set->x_siz);
set(ST_bg, MUIA_String_Contents ,&set->bg_picture[0]);
DoMethod(visible,MUIM_List_Clear,0L);
do
{
DoMethod(visible,MUIM_List_InsertSingle,list,MUIV_List_Insert_Bottom);
}
while(list=list->next);
DoMethod(visible,MUIM_List_Redraw,MUIV_List_Redraw_All);
DoMethod(ls_Switch,MUIM_List_Redraw,MUIV_List_Redraw_All);
}
int getNum(struct tm_gau_set *list)
{
int num=1;
while(list=list->next)num++;
return(num);
}
useDefault(struct tm_data *data)
{
struct tm_gau_set *many,
*act,
*old;
CopyMem((char *)&default_set,data->set,sizeof(struct tm_sys_set));
if(act=(struct tm_gau_set *)AllocVec(sizeof(struct tm_gau_set),0L))
{
many=&g1; data->list=act; CopyMem((char *)many,act,sizeof(struct tm_gau_set));
while(many=many->next)
{
old=act;
if(act=(struct tm_gau_set *)AllocVec(sizeof(struct tm_gau_set),0L))
{
old->next=act;
CopyMem((char *)many,act,sizeof(struct tm_gau_set));
}
else {act->next=0L;return;}
}
act->next=0L;
}
else data->list=0L;
}
BOOL loadSettings(Object *obj,struct tm_data *data, char *file)
{
ULONG my_file;
struct tm_gau_set *many,*act;
if(!maindata->set)maindata->set=AllocVec(sizeof(struct tm_sys_set),0L);
if(my_file=(UBYTE *)Open(file,MODE_OLDFILE))
{
if(!Read(my_file,data->set,(ULONG)sizeof(struct tm_sys_set)))
{
if(MUI_RequestA((Object *)xget(obj,MUIA_ApplicationObject),obj,0,"TinyMeterPrefs",GetStr(MM_BadPrefs_fmt),GetStr(MM_BadPrefs),NULL))
useDefault(data);
}
else
{
act=(struct tm_gau_set *)AllocVec(sizeof(struct tm_gau_set),NULL);
data->list=act; many=act;
while(Read(my_file,(char *)act,(ULONG)sizeof(struct tm_gau_set)))
{
many=act;
act=(struct tm_gau_set *)AllocVec(sizeof(struct tm_gau_set),NULL);
many->next=act;
}
many->next=NULL; FreeVec(act); act=NULL;
}
Close(my_file);
}
else if(MUI_RequestA((Object *)xget(obj,MUIA_ApplicationObject),obj,0,"TinyMeterPrefs",GetStr(MM_BadPrefs_fmt),GetStr(MM_BadPrefs),NULL))
useDefault(data);
data->num_of_gaug=getNum(data->list);
}
ULONG loadManager(struct IClass *cl,Object *obj, struct LoadSetMsg *msg)
{
char *file;
switch (msg->what)
{
case load_standard:
loadSettings(obj,maindata,"ENV:TinyMeter");
insertSettings(maindata->set,maindata->list);
break;
case load_file:
if(file=getfilename(obj,GetStr(MM_OpenTitle),"#?.tm",FALSE))
{
loadSettings(obj,maindata,file);
insertSettings(maindata->set,maindata->list);
}
break;
}
return((ULONG)DoSuperMethodA(cl,obj,msg));
}
///
/******************************************/
/* test settings and window snapping */
/******************************************/
///
#include <exec/memory.h>
#include <exec/ports.h>
#include <exec/execbase.h>
#define test_test 0
#define test_getwin 1
struct TestMessage
{
struct Message ts_Message;
ULONG MethodID;
struct tm_sys_set *set;
struct tm_gau_set *list;
ULONG posx,
posy,
sizx;
};
struct TestMessage *ts_msg;
struct MsgPort *p_port;
struct MsgPort *p_reply;
BOOL SafePutToPort(struct Message *message, char *portname)
{
struct MsgPort *port;
Forbid();
port = (struct MsgPort *)FindPort(portname);
if (port) PutMsg(port, (struct Message *) message);
Permit();
return(port ? TRUE : FALSE);
}
ULONG InitTestSettings()
{
if(
( ts_msg =(struct TestMessage *)AllocMem (sizeof(struct TestMessage),MEMF_PUBLIC|MEMF_CLEAR)) &&
( p_reply=(struct MsgPort *) CreatePort(0,0))
) return (1L);
else return (0L);
}
FreeTestSettings()
{
if(ts_msg) FreeMem (ts_msg,sizeof(struct TestMessage));
if(p_reply)DeletePort (p_reply);
}
struct TestMessage *TestSettings(ULONG type)
{
ULONG i,j;
struct tm_gau_set *act,
*all[64];
if( FindPort("TinyMeter") )
if( ts_msg && p_reply)
{
ts_msg->ts_Message.mn_Node.ln_Type = NT_MESSAGE;
ts_msg->ts_Message.mn_ReplyPort = p_reply;
ts_msg->ts_Message.mn_Length = sizeof ( struct TestMessage );
ts_msg->MethodID = type;
switch (type)
{
case test_test:
for(i=0;i<64;i++)all[i]=0L;
for(i=0;;i++)
{
DoMethod(visible,MUIM_List_GetEntry,i,&act);
if(!act) break;
if(i==63) break;
if(all[i]=AllocVec(sizeof(struct tm_gau_set),0L))
{
CopyMem(act, all[i], sizeof(struct tm_gau_set));
}
else return(0L);
}
for(j=0;j<i;j++)
{
all[j]->next=all[j+1];
}
ts_msg->list=all[0];
if(ts_msg->set = AllocVec(sizeof(struct tm_sys_set),0L))
{
CopyMem(maindata->set,ts_msg->set,sizeof(struct tm_sys_set));
}
else return(0L);
break;
case test_getwin:
ts_msg->list=0L;
ts_msg->set =0L;
break;
}
if (SafePutToPort((struct Message *)ts_msg,"TinyMeter"))
{
WaitPort(p_reply);
return(GetMsg(p_reply));
}
}
return(0L);
}
///
/******************************************/
/* snapWindow method */
/******************************************/
///
snapWindow(struct IClass *cl,Object *obj, struct Msg *msg)
{
struct TestMessage *testMsg;
testMsg=TestSettings(test_getwin);
set(IN_posx, MUIA_String_Integer ,testMsg->posx);
set(IN_posy, MUIA_String_Integer ,testMsg->posy);
set(IN_sizx, MUIA_String_Integer ,testMsg->sizx);
}
///
/******************************************/
/* save settings and the method for it */
/******************************************/
///
#define save_save 0
#define save_use 1
#define save_test 2
#define save_file 3
#define save_cancel 4
struct SaveSetMsg
{
ULONG MethodID;
ULONG what;
};
getSettings(struct tm_sys_set *set)
{
ULONG dummy;
struct ls_layout *src;
get(NB_col ,MUIA_Numeric_Value,&dummy);set->colums =(UWORD)dummy;
get(NB_bordx,MUIA_Numeric_Value,&dummy);set->win_border_x =(UWORD)dummy;
get(NB_bordy,MUIA_Numeric_Value,&dummy);set->win_border_y =(UWORD)dummy;
get(NB_spcx ,MUIA_Numeric_Value,&dummy);set->win_space_x =(UWORD)dummy;
get(NB_spcy ,MUIA_Numeric_Value,&dummy);set->win_space_y =(UWORD)dummy;
get(NB_wait ,MUIA_Numeric_Value,&dummy);set->start_wait =(UWORD)dummy;
get(NB_mem ,MUIA_Numeric_Value,&dummy);set->mem_refresh =(UWORD)dummy;
get(NB_vol ,MUIA_Numeric_Value,&dummy);set->vol_refresh =(UWORD)dummy;
DoMethod(ls_Switch,MUIM_List_GetEntry,1,&src); set->bg_type =src->entry_selected;
DoMethod(ls_Switch,MUIM_List_GetEntry,2,&src); set->win_backfront =src->entry_selected;
DoMethod(ls_Switch,MUIM_List_GetEntry,3,&src); set->win_move =src->entry_selected;
DoMethod(ls_Switch,MUIM_List_GetEntry,4,&src); set->bd_type =src->entry_selected;
DoMethod(ls_Switch,MUIM_List_GetEntry,6,&src); set->start_usescreennotify=src->entry_selected;
DoMethod(ls_Switch,MUIM_List_GetEntry,7,&src); set->Executive =src->entry_selected;
getColor(&set->bg_color, MN_Colors[0]);
getColor(&set->bright_color,MN_Colors[1]);
getColor(&set->dark_color, MN_Colors[2]);
get(ST_PubScr ,MUIA_String_Contents,&dummy); strcpy(&set->pub_name[0] ,(char *)dummy);
get(ST_bg ,MUIA_String_Contents,&dummy); strcpy(&set->bg_picture[0] ,(char *)dummy);
get(IN_sizx ,MUIA_String_Integer, &dummy); set->x_siz=(UWORD)dummy;
get(IN_posx ,MUIA_String_Integer, &dummy); set->x_pos=(UWORD)dummy;
get(IN_posy ,MUIA_String_Integer, &dummy); set->y_pos=(UWORD)dummy;
}
static saveSettings(Object *listv, struct tm_sys_set *set, char *file)
{
int i;
ULONG my_file;
struct tm_gau_set *act;
if(my_file=(ULONG)Open(file,MODE_NEWFILE))
{
Write(my_file,set,(ULONG)sizeof(struct tm_sys_set));
for (i=0;;i++)
{
DoMethod(listv,MUIM_List_GetEntry,i,&act);
if(!act) break;
if(i==63) break;
Write(my_file,act,(ULONG)sizeof(struct tm_gau_set));
}
Close(my_file);
}
}
ULONG saveManager(struct IClass *cl,Object *obj, struct SaveSetMsg *msg)
{
int i=0;
char *file;
getSettings(maindata->set);
switch (msg->what)
{
case save_save:
saveSettings(visible,maindata->set,"ENVARC:TinyMeter");
case save_use:
saveSettings(visible,maindata->set,"ENV:TinyMeter");
TestSettings(test_test);
while(pubscr[i]) FreeVec(pubscr[i++]);
DoMethod((Object *)xget(obj,MUIA_ApplicationObject),MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
return(0L);
case save_test:
TestSettings(test_test);
return(obj);
case save_file:
if(file=getfilename(obj,GetStr(MM_SaveTitle),"#?.tm",TRUE))
saveSettings(visible,maindata->set,file);
break;
case save_cancel:
loadSettings(obj,maindata,"ENV:TinyMeter");
insertSettings(maindata->set,maindata->list);
TestSettings(test_test);
DoMethod((Object *)xget(obj,MUIA_ApplicationObject),MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
break;
}
return((ULONG)DoSuperMethodA(cl,obj,msg));
}
///
/******************************************/
/* other MainWindow methods */
/******************************************/
///
struct DoubleClkMsg
{
ULONG MethodID;
struct MainData *data;
};
static ULONG Dis_DoubleClick2(struct IClass *cl,Object *obj, struct DoubleClkMsg *msg)
{
struct ls_layout *src;
DoMethod(ls_Switch,MUIM_List_GetEntry,MUIV_List_GetEntry_Active,&src);
if(src)
{
if(src->entry_max>0)
{
src->entry_selected++;if(src->entry_max<src->entry_selected)src->entry_selected=0;
DoMethod(ls_Switch,MUIM_List_Redraw,MUIV_List_Redraw_Active);
}
return(DoSuperMethodA(cl,obj,msg));
}
else return(0L);
}
static ULONG Dis_DoubleClick1(struct IClass *cl,Object *obj, struct DoubleClkMsg *msg)
{
char *my_ptr;
DoMethod(ls_PubScr,MUIM_List_GetEntry,MUIV_List_GetEntry_Active,&my_ptr);
if(my_ptr)
{
set(ST_PubScr,MUIA_String_Contents,my_ptr);
DoMethod(PO_PubScr,MUIM_Popstring_Close,0L);
return(DoSuperMethodA(cl,obj,msg));
}
else return(0L);
}
ULONG MainWindow_Finish(struct IClass *cl,Object *obj,Msg *msg)
{
int i=0;
struct MainData *data;
data=INST_DATA(cl,obj);
while(pubscr[i++]) FreeVec(pubscr[i]); pubscr[i]=0;
DoMethod((Object *)xget(obj,MUIA_ApplicationObject),MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
return((ULONG)0L);
}
static GetPubScreens()
{
struct List *PubScreenList;
struct PubScreenNode *ScreenNode;
int i=0;
PubScreenList = LockPubScreenList();
for(ScreenNode=(struct PubScreenNode *)PubScreenList->lh_Head;ScreenNode->psn_Node.ln_Succ;ScreenNode=(struct PubScreenNode *)ScreenNode->psn_Node.ln_Succ)
{
pubscr[i]=(char *)AllocVec(256L,0L);
strcpy(pubscr[i],ScreenNode->psn_Node.ln_Name);
i++;
}
UnlockPubScreenList();
}
static ULONG MainWindow_New(struct IClass *cl,Object *obj,Msg *msg)
{
struct MainData *data;
int i;
InitBitMap(&my_bmp,3,41,192);
my_bmp.Planes[0]=&tmp_logoData[0];
my_bmp.Planes[1]=&tmp_logoData[576];
my_bmp.Planes[2]=&tmp_logoData[1152];
GetPubScreens();
if (obj = (Object *)
DoSuperNew(cl,obj,
MUIA_Window_Title, GetStr(MO_Title),
MUIA_Window_ID , MAKE_ID('T','I','N','Y'),
WindowContents, VGroup, ButtonFrame,
Child, HGroup,
Child, VGroup, MUIA_Background, MUII_SHADOW,
Child, HVSpace,
Child, BitmapObject,
MUIA_Bitmap_Bitmap, &my_bmp,
MUIA_Bitmap_Width, 41,
MUIA_Bitmap_Height, 192,
MUIA_Bitmap_SourceColors, &tmp_logoPaletteRGB32[1],
MUIA_FixHeight, 192,
MUIA_FixWidth, 41,
MUIA_ShortHelp, "Greets to: hANGKOK, pEPE, bEZZZERK, tRACER, rALPH...",
End,
End,
Child, RegisterGroup(mainlister),
MUIA_Register_Frame, TRUE,
Child, HGroup,
Child, lv_Switch=(Object *)ListviewObject,
MUIA_Frame, MUIV_Frame_InputList,
MUIA_Listview_Input, TRUE,
MUIA_Listview_DoubleClick, TRUE,
MUIA_Listview_List, ls_Switch=(Object *)ListObject,
MUIA_List_ConstructHook, &lay_ConstructHook,
MUIA_List_DestructHook , &lay_DestructHook,
MUIA_List_DisplayHook , &lay_DisplayHook,
MUIA_List_Format , "MIW=50 MAW=100 BAR,",
MUIA_List_Active, MUIV_List_Active_Top,
End,
End,
Child, RegisterGroup(sublister),
MUIA_Register_Frame, TRUE,
Child, ColGroup(2),
Child, HVSpace,
Child, HVSpace,
Child, Label(GetStr(MO_MemRefresh)),
Child, ColGroup(2), Child, NB_mem=MUI_MakeObject(MUIO_NumericButton,NULL,1,100,GetStr(MO_fmt_seconds)), Child, HVSpace, End,
Child, Label(GetStr(MO_VolRefresh)),
Child, ColGroup(2), Child, NB_vol=MUI_MakeObject(MUIO_NumericButton,NULL,1,100,GetStr(MO_fmt_seconds)), Child, HVSpace, End,
Child, Label(GetStr(MO_Wait)),
Child, ColGroup(2), Child, NB_wait=MUI_MakeObject(MUIO_NumericButton,NULL,0,100,GetStr(MO_fmt_seconds)), Child, HVSpace, End,
Child, HVSpace,
Child, HVSpace,
End,
Child, ColGroup(2),
Child, HVSpace,
Child, HVSpace,
Child, Label(GetStr(MO_Public)),
Child, PO_PubScr=(Object *)PopobjectObject,
MUIA_Popstring_String, ST_PubScr=(Object *)String(NULL,80),
MUIA_Popstring_Button, PopButton(MUII_PopUp),
MUIA_Popobject_Object, lv_PubScr=(Object *)ListviewObject,
MUIA_Frame, MUIV_Frame_InputList,
MUIA_Listview_Input, TRUE,
MUIA_Listview_DoubleClick, TRUE,
MUIA_Listview_List, ls_PubScr=(Object *)ListObject,
MUIA_List_Active, MUIV_List_Active_Top,
MUIA_List_SourceArray,&pubscr[0],
End,
End,
End,
Child, Label(GetStr(MO_WindowPos)),
Child, ColGroup(2),
Child, IN_posx=StringObject,
StringFrame,
MUIA_String_Accept , "0123456879",
End,
Child, IN_posy=StringObject,
StringFrame,
MUIA_String_Accept , "0123456879",
End,
End,
Child, Label(GetStr(MO_WindowSiz)),
Child, ColGroup(2),
MUIA_Group_SameWidth, TRUE,
Child, IN_sizx=StringObject,
StringFrame,
MUIA_String_Accept , "0123456879",
End,
Child, BT_Snap=SimpleButton(GetStr(MO_Snap)),
End,
Child, Label(GetStr(MO_BackgroundPic)),
Child, ST_bg=PopaslObject,
MUIA_Popstring_String, String(NULL,80),
MUIA_Popstring_Button, PopButton(MUII_PopFile),
ASLFO_TitleText , GetStr(MO_SelectBg),
End,
Child, Label(GetStr(MO_BackgroundCol)),
Child, ColGroup(3),Child, HVSpace, Child, MN_Colors[0]=MakePen(), Child, HVSpace, End,
Child, Label(GetStr(MO_BrightCol)),
Child, ColGroup(3),Child, HVSpace, Child, MN_Colors[1]=MakePen(), Child, HVSpace, End,
Child, Label(GetStr(MO_DarkCol)),
Child, ColGroup(3),Child, HVSpace, Child, MN_Colors[2]=MakePen(), Child, HVSpace, End,
Child, HVSpace,
Child, HVSpace,
End,
Child, VGroup,
Child, HVSpace,
Child, ColGroup(2),
Child, Label(GetStr(MO_Colums)),
Child, ColGroup(2), Child, NB_col=MUI_MakeObject(MUIO_NumericButton,NULL,1,32,"%3ld"), Child, HVSpace, End,
Child, Label(GetStr(MO_SpaceX)),
Child, ColGroup(2), Child, NB_spcx=MUI_MakeObject(MUIO_NumericButton,NULL,0,256,GetStr(MO_fmt_pixels)), Child, HVSpace, End,
Child, Label(GetStr(MO_SpaceY)),
Child, ColGroup(2), Child, NB_spcy=MUI_MakeObject(MUIO_NumericButton,NULL,0,256,GetStr(MO_fmt_pixels)), Child, HVSpace, End,
Child, Label(GetStr(MO_BordX)),
Child, ColGroup(2), Child, NB_bordx=MUI_MakeObject(MUIO_NumericButton,NULL,0,256,GetStr(MO_fmt_pixels)), Child, HVSpace, End,
Child, Label(GetStr(MO_BordY)),
Child, ColGroup(2), Child, NB_bordy=MUI_MakeObject(MUIO_NumericButton,NULL,0,256,GetStr(MO_fmt_pixels)), Child, HVSpace, End,
End,
Child, HVSpace,
End,
End,
End,
Child, VGroup,
Child, NewObject(CL_ChooseFields->mcc_Class,NULL,TAG_DONE),
End,
End,
End,
Child, HGroup,
Child, BT_Save = (Object *)SimpleButton(GetStr(MO_Save)),
Child, BT_Use = (Object *)SimpleButton(GetStr(MO_Use)),
Child, BT_Test = (Object *)SimpleButton(GetStr(MO_Test)),
Child, BT_Cancel = (Object *)SimpleButton(GetStr(MO_Cancel)),
End,
End,
End)
{
data=INST_DATA(cl,obj);
set(BT_Save ,MUIA_ShortHelp,GetStr(MH_Save));
set(BT_Use ,MUIA_ShortHelp,GetStr(MH_Use));
set(BT_Test ,MUIA_ShortHelp,GetStr(MH_Test));
set(BT_Cancel ,MUIA_ShortHelp,GetStr(MH_Cancel));
set(NB_mem ,MUIA_ShortHelp,GetStr(MH_MemRefresh));
set(NB_vol ,MUIA_ShortHelp,GetStr(MH_VolRefresh));
set(NB_wait ,MUIA_ShortHelp,GetStr(MH_Wait));
set(lv_Switch ,MUIA_ShortHelp,GetStr(MH_Flags));
set(PO_PubScr ,MUIA_ShortHelp,GetStr(MH_Public));
set(IN_posx ,MUIA_ShortHelp,GetStr(MH_PosX));
set(IN_posy ,MUIA_ShortHelp,GetStr(MH_PosY));
set(IN_sizx ,MUIA_ShortHelp,GetStr(MH_SizX));
set(BT_Snap ,MUIA_ShortHelp,GetStr(MH_Snap));
set(ST_bg ,MUIA_ShortHelp,GetStr(MH_BackgroundPic));
set(MN_Colors[0],MUIA_ShortHelp,GetStr(MH_BackgroundCol));
set(MN_Colors[1],MUIA_ShortHelp,GetStr(MH_BrightCol));
set(MN_Colors[2],MUIA_ShortHelp,GetStr(MH_DarkCol));
set(NB_col ,MUIA_ShortHelp,GetStr(MH_Colums));
set(NB_spcx ,MUIA_ShortHelp,GetStr(MH_SpaceX));
set(NB_spcy ,MUIA_ShortHelp,GetStr(MH_SpaceX));
set(NB_bordx ,MUIA_ShortHelp,GetStr(MH_BordX));
set(NB_bordy ,MUIA_ShortHelp,GetStr(MH_BordY));
DoMethod(BT_Snap ,MUIM_Notify,MUIA_Pressed ,FALSE,obj,1,Dis_ID_Snap);
DoMethod(BT_Save ,MUIM_Notify,MUIA_Pressed ,FALSE,obj,2,Dis_ID_Save ,save_save);
DoMethod(BT_Use ,MUIM_Notify,MUIA_Pressed ,FALSE,obj,2,Dis_ID_Save ,save_use );
DoMethod(BT_Test ,MUIM_Notify,MUIA_Pressed ,FALSE,obj,2,Dis_ID_Save ,save_test);
DoMethod(lv_PubScr,MUIM_Notify,MUIA_Listview_DoubleClick ,TRUE ,obj,2,Dis_ID_DoubleClick1,data);
DoMethod(lv_Switch,MUIM_Notify,MUIA_Listview_DoubleClick ,TRUE ,obj,1,Dis_ID_DoubleClick2);
DoMethod(obj,MUIM_Notify,MUIA_Window_MenuAction,MEN_SAVE,obj,2,Dis_ID_Save,save_file);
DoMethod(obj,MUIM_Notify,MUIA_Window_MenuAction,MEN_OPEN,obj,2,Dis_ID_Load,load_file);
DoMethod(BT_Cancel,MUIM_Notify,MUIA_Pressed ,FALSE,obj,2,Dis_ID_Save ,save_cancel);
for(i=0;i<8;i++)DoMethod(ls_Switch,MUIM_List_InsertSingle,&switches[i],MUIV_List_Insert_Bottom);
DoMethod(obj,Dis_ID_Load,load_standard);
}
return((ULONG)obj);
}
///
static __saveds __asm ULONG MainWindowDispatcher(__a0 struct IClass *cl,__a2 Object *obj,__a1 Msg msg)
{
switch (msg->MethodID)
{
case OM_NEW : return (MainWindow_New (cl,obj,(APTR)msg));
case Dis_ID_Finish : return (MainWindow_Finish (cl,obj,(APTR)msg));
case Dis_ID_DoubleClick1 : return (Dis_DoubleClick1 (cl,obj,(APTR)msg));
case Dis_ID_DoubleClick2 : return (Dis_DoubleClick2 (cl,obj,(APTR)msg));
case Dis_ID_Save : return (saveManager (cl,obj,(APTR)msg));
case Dis_ID_Snap : return (snapWindow (cl,obj,(APTR)msg));
case Dis_ID_Load : return (loadManager (cl,obj,(APTR)msg));
}
return (DoSuperMethodA (cl,obj,(APTR)msg));
}
/*************************************************/
/* Init all classes */
/*************************************************/
///
VOID ExitClasses(VOID)
{
if (CL_FieldsList ) MUI_DeleteCustomClass(CL_FieldsList);
if (CL_ChooseFields) MUI_DeleteCustomClass(CL_ChooseFields);
if (CL_MainWindow) MUI_DeleteCustomClass(CL_MainWindow);
if (CL_Composer) MUI_DeleteCustomClass(CL_Composer);
}
BOOL InitClasses(VOID)
{
CL_MainWindow = MUI_CreateCustomClass(NULL,MUIC_Window ,NULL, sizeof(struct MainData) ,MainWindowDispatcher);
CL_FieldsList = MUI_CreateCustomClass(NULL,MUIC_List ,NULL, sizeof(struct FieldsList_Data) ,FieldsList_Dispatcher);
CL_ChooseFields = MUI_CreateCustomClass(NULL,MUIC_Group ,NULL, sizeof(struct ChooseFields_Data) ,ChooseFields_Dispatcher);
CL_Composer = MUI_CreateCustomClass(NULL,MUIC_Window ,NULL, sizeof(struct Composer_Data) ,ComposerDispatcher);
if ( CL_FieldsList && CL_ChooseFields && CL_MainWindow && CL_Composer ) return(TRUE);
ExitClasses();
return(FALSE);
}
///
/*************************************************/
/* Main: MUIApplication and Aboutwindow */
/*************************************************/
///
#include <exec/tasks.h>
#ifdef _DCC
int brkfunc(void) { return(0); }
#endif
void LocalizeSwitches(struct ls_layout *ll)
{
int i;
for (;ll->entry_desc!=NULL;ll++)
{
ll->entry_desc=GetStr((int)ll->entry_desc);
for(i=0;i<6;i++)
{
if (ll->entry[i]!=NULL) ll->entry[i]=GetStr((int)ll->entry[i]);
else ll->entry[i]=" ";
}
}
}
BOOL quit_not;
int main(int argc, char *argv[])
{
Object *app,*window;
struct Task *me;
if (MUIMasterBase = OpenLibrary(MUIMASTER_NAME,MUIMASTER_VMIN))
{
if(me= FindTask(NULL))
{
if((me->tc_SPUpper-me->tc_SPLower)>8000)
{
if(maindata=(struct tm_data *)AllocVec(sizeof(struct tm_data),MEMF_CLEAR))
{
if(InitTestSettings())
{
InitClasses();
InitLocale();
LocalizeNewMenu(MenuData1);
LocalizeNewMenu(CmpMenuData);
LocalizeSwitches(switches);
LocalizeStringArray(gau_types);
LocalizeStringArray(types);
LocalizeStringArray(indent);
LocalizeStringArray(mainlister);
LocalizeStringArray(sublister);
LocalizeStringArray(regcomposer);
strcpy(&default_gauge.label[0],GetStr(MDef_Label));
strcpy(&default_gauge.format[0],GetStr(MDef_fmt));
strcpy(&default_gauge.expansion[0],GetStr(MDef_Device));
app = ApplicationObject,
MUIA_Application_Title , "TinyMeterPrefs V4.01",
MUIA_Application_Version , "$VER: TinyMeterPrefs V4.01 (22.11.95)",
MUIA_Application_Copyright , "©1994-95, Tinic Urou",
MUIA_Application_Author , "Tinic Urou",
MUIA_Application_Description, GetStr(MA_Description),
MUIA_Application_Base , "TMPREFS",
MUIA_Application_Menustrip , MN_Main = MUI_MakeObject(MUIO_MenustripNM,MenuData1,0),
SubWindow , window = (Object *)NewObject(CL_MainWindow->mcc_Class,NULL,TAG_DONE),
SubWindow , WI_About = WindowObject,
MUIA_Window_Title, GetStr(MA_About_Title),
MUIA_Window_ID , MAKE_ID('T','M','A','B'),
WindowContents, VGroup, ButtonFrame,
Child, BodychunkObject,
MUIA_FixWidth , ABOUT_WIDTH ,
MUIA_FixHeight , ABOUT_HEIGHT,
MUIA_Bitmap_Width , ABOUT_WIDTH ,
MUIA_Bitmap_Height , ABOUT_HEIGHT,
MUIA_Bodychunk_Depth , ABOUT_DEPTH ,
MUIA_Bodychunk_Body , (UBYTE *)about_body,
MUIA_Bodychunk_Compression, ABOUT_COMPRESSION,
MUIA_Bodychunk_Masking , ABOUT_MASKING,
MUIA_Bitmap_SourceColors , (ULONG *)about_colors,
MUIA_Bitmap_Transparent , 0,
End,
End,
End,
SubWindow , WI_HelpFmt = WindowObject,
MUIA_Window_Title, GetStr(MH_FormatHelp),
MUIA_Window_ID , MAKE_ID('T','H','L','P'),
WindowContents, VGroup,
Child, ScrollgroupObject,
MUIA_Scrollgroup_Contents, VirtgroupObject,TextFrame,
Child, TextObject,
MUIA_Text_Contents, GetStr(MOH_Format),
End,
End,
End,
End,
End,
SubWindow , WI_HelpClock = WindowObject,
MUIA_Window_Title, GetStr(MH_ClockHelp),
MUIA_Window_ID , MAKE_ID('T','H','L','P'),
WindowContents, VGroup,
Child, ScrollgroupObject,
MUIA_Scrollgroup_Contents, VirtgroupObject,TextFrame,
Child, TextObject,
MUIA_Text_Contents, GetStr(MOH_Clock),
End,
End,
End,
End,
End,
End;
if(app)
{
DoMethod(app ,MUIM_Notify,MUIA_Application_MenuAction,MEN_QUIT ,app ,2,MUIM_Application_ReturnID ,MUIV_Application_ReturnID_Quit);
DoMethod(app ,MUIM_Notify,MUIA_Application_MenuAction,MEN_ABOUT,WI_About,3,MUIM_Set ,MUIA_Window_Open,TRUE);
DoMethod(WI_About ,MUIM_Notify,MUIA_Window_CloseRequest ,TRUE ,WI_About,3,MUIM_Set ,MUIA_Window_Open,FALSE);
DoMethod(WI_HelpFmt ,MUIM_Notify,MUIA_Window_CloseRequest ,TRUE ,WI_HelpFmt,3,MUIM_Set ,MUIA_Window_Open,FALSE);
DoMethod(WI_HelpClock,MUIM_Notify,MUIA_Window_CloseRequest ,TRUE ,WI_HelpClock,3,MUIM_Set ,MUIA_Window_Open,FALSE);
DoMethod(window,MUIM_Notify,MUIA_Window_CloseRequest,TRUE, app,2,MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
set(window,MUIA_Window_Open,TRUE);
{
ULONG sigs = 0;
while (DoMethod(app,MUIM_Application_NewInput,&sigs) != MUIV_Application_ReturnID_Quit)
{
if (sigs)
{
sigs = Wait(sigs | SIGBREAKF_CTRL_C);
if (sigs & SIGBREAKF_CTRL_C) break;
}
}
}
MUI_DisposeObject(app);
}
ExitLocale();
ExitClasses();
FreeTestSettings();
}
if(maindata->set)FreeVec(maindata->set);
FreeVec(maindata);
}
}
else MUI_RequestA(NULL,NULL,0,"Early Startup","OK","Stacksize too small!\n\nA minimum of 8192 bytes is needed.",NULL);
}
CloseLibrary(MUIMasterBase);
}
quit_not=FALSE;
}
int wbmain(struct WBStartup *wb_startup)
{
return (main(0, (char **)wb_startup));
}
///